package com.swn.common.util;

import java.util.Map;

import javax.servlet.ServletContextEvent;

import org.apache.log4j.Logger;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.WebApplicationContextUtils;

import redis.clients.jedis.Jedis;



/**
 * ContextLoaderListener扩展类：用于加载spring容器、以及其他监听任务
 * 
 * @author taozhaocai
 * @Date 2016-6-3  下午2:40:13
 * @company 山东成功信息技术有限公司
 */
public class ContextLoaderListenerImpl extends ContextLoaderListener {
	private static Logger logger = Logger.getLogger("ContextLoaderListenerImpl.class");



	/*
	 * @see org.springframework.web.context.ContextLoaderListener#contextInitialized(javax.servlet.ServletContextEvent)
	 */
	public void contextInitialized(ServletContextEvent event) {
		super.contextInitialized(event);
		logger.info("监听在启动.......");
		ServiceLocator.setContext(WebApplicationContextUtils.getWebApplicationContext(event.getServletContext()));
		//DbTableUtil.initOracleTable(null);
		logger.info("监听启动完毕."); 
		//将当前店铺名称和logoUrl存入redis
		
	}
	
	/*
	 * @see org.springframework.web.context.ContextLoaderListener#contextDestroyed(javax.servlet.ServletContextEvent)
	 */
	public void contextDestroyed(ServletContextEvent event) {
		super.contextDestroyed(event);
		logger.info("ApplicationContext在运行.......");
		ServiceLocator.setContext(null);
		logger.info("ApplicationContext已经被销毁.");
	}
	
}
